Table of Contents Previous Section

The Role of Scripts in a WebObjects Application

In a WebObjects application, a WebScript typically includes the following ingredients:

In most cases, a script has a corresponding declarations file and HTML template. The declarations file provides a mapping between the actions and variables defined in the script, and the HTML elements that will be dynamically generated and then substituted in the HTML template.The three files in a group have the same base name but with different extensions; for example, Main.wos (script), Main.wod (declarations), and Main.html (template). These application resources are used by a corresponding WOWebScriptComponentController to prepare responses to user requests. Most commonly a WOWebScriptComponentController represents a single page in a WebObjects application, though one WOWebScriptComponentController can be nested inside of another.

In a WebObjects application you generally put each group of three files (the script, the declaration, and the HTML template) into a directory that has the same base name and the extension .wo. So, for example, you can have a directory Main.wo that contains the files Main.wos, Main.wod, and Main.html. Each group of three files is called a component. The script associated with a component (in this example, Main.wos) is called a component script.

The Application Script

Often, in addition to having multiple components (that is, subdirectories that contain a script, a declarations file, and an HTML template), a WebScript application also has an application script. This script is where you declare and initialize global and session variables.

The application script has the name Application.wos, and it resides immediately under the application directory.

Table of Contents Next Section